
#include "Vector3D.h"

//Returns a fandom double from 0 to 1
double rnd()			
{ 
    return (double)rand() / (double)RAND_MAX; 
}

//Returns a random vector with components from 0 to 1
Vector3D RandVector3D()	
{ 
    return Vector3D(rnd(), rnd(), rnd()); 
}

Vector3D RandSphere3D()
{
    
    //double r = rnd() * 0.5 + 0.5;
    //double theta = rnd() * 2 * PI;
    //double phi = rnd() * PI;
    
    Vector3D v = RandVector3D() * 2.f - Vector3D(1.f, 1.f, 1.f);
    
    while (v.Length2() > 1)
	v = RandVector3D() * 2.f - Vector3D(1.f, 1.f, 1.f);
    
    //return Vector3D(r*cos(theta)*sin(phi), r*sin(theta)*sin(phi), r*cos(phi));
    return v;
    
}

void RandomSeed()
{	
    //srand(GetTickCount());	
}
